﻿using System;
using EnvDTE;
using EnvDTE80;

namespace ForgeIt.Commands
{
    ///<summary>
    ///</summary>
    public class FileCommand : BaseCommand
    {
        ///<summary>
        ///</summary>
        ///<param name="applicationObject"></param>
        ///<param name="connectorClass"></param>
        public FileCommand(DTE2 applicationObject, Connect connectorClass)
            : base(applicationObject, connectorClass)
        {
            validExtensions.Add(".cs");
            validExtensions.Add(".csproj");
        }

        ///<summary>
        ///</summary>
        ///<param name="CmdName"></param>
        ///<param name="ExecuteOption"></param>
        ///<param name="VariantIn"></param>
        ///<param name="VariantOut"></param>
        ///<param name="Handled"></param>
        ///<exception cref="NotImplementedException"></exception>
        public override void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled)
        {
            UIHierarchy solutionExplorer = ApplicationObject.ToolWindows.SolutionExplorer;

            var items = solutionExplorer.SelectedItems as Array;

            if (items == null ) return;

            for (int i = 1; i < items.Length; i++)
            {
                
            }
            
            foreach (UIHierarchyItem hierarchyItem in items)
            {

                ProjectItem prjItem = hierarchyItem.Object as ProjectItem;
                if (prjItem == null)
                {
                    Log("Null entry?");
                    continue;
                }
                Log("Selected: " + prjItem.Name + " - CheckedOut (" +
                    ApplicationObject.SourceControl.IsItemCheckedOut(prjItem.Name) + ")");

            }
           
        }
    }
}
